package com.bckj.fastboot.upms.biz.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.core.page.PageSupport;
import com.bckj.fastboot.upms.api.dto.ClientAuthInfo;
import com.bckj.fastboot.upms.api.dto.SysOauthClientDetailsQuery;
import com.bckj.fastboot.upms.api.dto.SysOauthClientDetailsRequest;
import com.bckj.fastboot.upms.api.service.SysOauthClientDetailsRemoteService;
import com.bckj.fastboot.upms.api.vo.SysOauthClientDetailsVO;
import com.bckj.fastboot.upms.biz.service.SysOauthClientDetailsService;
import org.springframework.web.bind.annotation.*;

import lombok.RequiredArgsConstructor;
import java.util.List;


/**
 * 客户端信息表(SysOauthClientDetails)表控制层
 *
 * @author wfc
 * @since 2023-09-11 17:38:49
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("client")
public class SysOauthClientDetailsController implements SysOauthClientDetailsRemoteService {
    /**
     * 服务
     */
	private final SysOauthClientDetailsService sysOauthClientDetailsService;
	
    /**
	 * 列表
	 *
	 * @param query req
	 * @return list
	 */
    @Override
	@GetMapping("page")
	public PageResult<SysOauthClientDetailsVO> page(SysOauthClientDetailsQuery query) {
		IPage<SysOauthClientDetailsVO> page = PageSupport.page(() -> sysOauthClientDetailsService.list(query));
		return PageResult.of(page);
	}
	
    /**
	 * 列表
	 *
	 * @param query req
	 * @return list
	 */
    @Override
	@GetMapping("list")
	public List<SysOauthClientDetailsVO> list(SysOauthClientDetailsQuery query) {
		return sysOauthClientDetailsService.list(query);
	}

	/**
	 * 增加
	 *
	 * @param request req
	 * @return boolean
	 */
	@Override
	@PostMapping
	public boolean save(@RequestBody SysOauthClientDetailsRequest request) {
		return sysOauthClientDetailsService.save(request);
	}

	/**
	 * 修改
	 *
	 * @param request req
	 * @return boolean
	 */
	@Override
	@PutMapping
	public boolean update(@RequestBody SysOauthClientDetailsRequest request) {
		return sysOauthClientDetailsService.update(request);
	}

	/**
	 * 移除
	 *
	 * @param id id
	 * @return boolean
	 */
	@Override
	@DeleteMapping("{id}")
	public boolean remove(@PathVariable Long id) {
		return sysOauthClientDetailsService.remove(id);
	}

	/**
	 * 详情
	 *
	 * @param id id
	 * @return vo
	 */
	@Override
	@GetMapping("{id}")
	public SysOauthClientDetailsVO details(@PathVariable Long id) {
		return sysOauthClientDetailsService.details(id);
	}

	@Override
	public ClientAuthInfo findByClientId(String clientId) {
		return sysOauthClientDetailsService.findByClientId(clientId);
	}
}

